var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/mern-starter');

var group_Schema = mongoose.Schema({
  marathon_id: String, //id1
  name: String, //id2
  members: String,
  captain: String,
  detail: String,
  url: String,
  photo: String,
  level: String  //"1"一轮投票， "2"二轮投票
});

var groups = mongoose.model('hackson_groups', group_Schema);

var marathon_Schema = mongoose.Schema({
  name: String,  //id
  start_time: String,
  stop_time: String,
  address: String,
  organizer: String,
  participants: String,
  detail: String,
  votes_for_teacher: String,
  weight_for_teacher: String,
  votes_for_student: String,
  dimensions_for_vote: String,
  status: String, //0：未开始 1: 报名  2：投票 3：投票截止 4: 二轮投票 5： 二轮投票截止 6：已结束
  students: String
});

var marathons = mongoose.model('hackson_marathons', marathon_Schema);

var trace_Schema = mongoose.Schema({
  role: String, // 1 student,  2 teacher, 3 admin, 4 donator
  id: String,
  marathon_id: String, //id1
  name: String, //id2
  time: String
});

var traces = mongoose.model('hackson_traces', trace_Schema);

var vote_Schema = mongoose.Schema({
  role: String, // 1 student,  2 teacher, 3 admin, 4 donator
  id: String,
  marathon_id: String, //id1
  vote: String, //id2
  level: String  //"1"一轮投票， "2"二轮投票
});

var votes = mongoose.model('hackson_votes', vote_Schema);


module.exports = {
  groups: groups,
  marathons:marathons,
  traces:traces,
  votes: votes
};
